package ejb.entities;

import java.io.Serializable;

import javax.persistence.*;

import ejb.dto.EscursioneDTO;

import java.sql.Time;

/**
 * The persistent class for the escursions database table.
 * 
 */
@Entity
@Table(name = "escursions")
@NamedQueries({
		@NamedQuery(name = "Escursion.findAll", query = "SELECT e FROM Escursion e"),
		@NamedQuery(name = "Escursion.findByDateAndCity", query = "SELECT e FROM Escursion e WHERE e.basicproduct.startdate = :dataInizio AND e.city LIKE :citta"),
		@NamedQuery(name = "Escursion.findInDateAndByCity", query = "SELECT e FROM Escursion e WHERE e.basicproduct.startdate >= :dataInizio AND e.basicproduct.enddate <= :dataFine AND e.city LIKE :citta"),
		@NamedQuery(name = "Escursion.findByDate", query = "SELECT e FROM Escursion e  WHERE e.basicproduct.startdate = :dataInizio"), })
public class Escursion implements Serializable {
	private static final long serialVersionUID = 1L;

	public static final String FIND_ALL = "Escursion.findAll";
	public static final String FIND_DATE_CITY = "Escursion.findByDateAndCity";
	public static final String FIND_DATE = "Escursion.findByDate";
	public static final String FIND_INDATE_BYCITY = "Escursion.findInDateAndByCity";

	@Id
	@GeneratedValue(strategy = GenerationType.TABLE)
	private int uscursionid;

	private String city;

	private Time starthour;

	// bi-directional one-to-one association to Basicproduct
	@OneToOne
	@PrimaryKeyJoinColumn(name = "uscursionid") // readonly
	private Basicproduct basicproduct;

	public Escursion() {
	}

	public Escursion(EscursioneDTO escursioneDTO) {
		this.city = escursioneDTO.getCitta();
		this.starthour = new Time(escursioneDTO.getOraInizio().getTime());
	}

	public int getUscursionid() {
		return this.uscursionid;
	}

	public void setUscursionid(int uscursionid) {
		this.uscursionid = uscursionid;
	}

	public String getCity() {
		return this.city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public Time getStarthour() {
		return this.starthour;
	}

	public void setStarthour(Time starthour) {
		this.starthour = starthour;
	}

	public Basicproduct getBasicproduct() {
		return this.basicproduct;
	}

	public void setBasicproduct(Basicproduct basicproduct) {
		this.basicproduct = basicproduct;
	}

}